   function im2 = ApplyContrastBrightness(im,brightness,contrast)
       if brightness < 0
            im = im*(1+brightness);
        else
            im = im + (255-im)*brightness;
        end
        im2 = uint8((int16(im)-128) * (tan(contrast + 1) * pi/4)) + 128; 
    end